#ifndef _TIMER_H_
#define _TIMER_H_

//

class Timer
{
public:
	Timer(float time = 0, bool isEnable = true)
	{
		m_currentTime = time;
		m_isEnable = isEnable;
	}

public:
	void SetTime(float time)
	{
		m_currentTime = time;
	}
	void SetEnable(bool enable)
	{
		m_isEnable = enable;
	}
	void Update(float timeStep)
	{
		if(m_isEnable)
		{
			m_currentTime -= timeStep;
			if(m_currentTime < 0)
			{
				m_currentTime = 0;
			}
		}
	}
	bool IsDone() const {return m_isEnable&&( m_currentTime <= 0);}
	float GetTime() const {return m_currentTime;}

protected:
	float m_currentTime;
	bool m_isEnable;
};

class ActiveTimer
{
public:
	ActiveTimer(float duration = 0)
	{
		SetTime(duration);
	}

public:
	void SetTime(float time)
	{
		m_currentTime = ((time > 0)? time : 0); m_isActive = (m_currentTime > 0);
	}
	void Update(float timeStep)
	{
		m_currentTime -= timeStep; if (m_currentTime < 0) { m_currentTime = 0; }
	}
	bool IsDone() const { return m_currentTime == 0 ; }
	bool IsActive() const { return m_isActive ; }
	 float GetTime() const {return m_currentTime;}

protected:
	float m_currentTime;
	bool m_isActive;
};
#endif //_TIMER_H_